#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    while(cin >> n){
        cout << "------------------------------------------------------------\n";
        int len = 0;
        vector<string> v;
        while(n--){
            string t; cin >> t;
            if(t.size()>len) len = t.size();
            v.push_back(t);
        }
        sort(v.begin(), v.end());
        int C = (60 - len)/(len+2) + 1;
        int R = ((int)v.size()-1)/C + 1;
        for (int i = 0; i < R; ++i) {
            for (int j = 0; j < C; ++j) {
                int id = i+R*j;
                if(id < v.size()){
                    if(j<=C-2) cout << left << setw(len+2) << v[id];
                    else  cout << left << setw(len) << v[id];
                }
            }
            cout << "\n";
        }
    }
    return 0;
}
